<?php 
global $site_info;

if(!empty($category)):
$cat_name = $this->_global->_unserialize($category->cat_name);
$cat_desc = $this->_global->_unserialize($category->cat_desc);
$site_info['site_title']= $cat_name[$this->session->userdata('lan')]['title'].' - '.$site_info['site_title'];

endif;
?>

<div class="content" style="border: none;">

<div class="content" style="float: none;margin-top: 5px;">

<h1 class="title"><?php echo $cat_name[$this->session->userdata('lan')]['title']; ?></h1>
<?php //$posts = _get_posts($category->cat_id);
    if(!empty($posts)){
        foreach($posts as $post){
            $title = $this->_global->_unserialize($post->post_title);
            $title = $title[$this->session->userdata('lan')]['post_title'];
            $alias = $this->_global->_unserialize($post->seo_alias);
            $alias = $alias[$this->session->userdata('lan')]['alias'];
            $desc = $this->_global->_unserialize($post->post_desc);
            $desc = $desc[$this->session->userdata('lan')]['post_desc'];
            $p =  $this->_global->_unserialize($post->post_content);
            $p = $p[$this->session->userdata('lan')]['post_content'];
?>
<div class="posts" style="width:95%;float:none;">
    <h2><?php echo anchor('news/c'.$post->cat_id.'/'.$alias.'-'.$post->post_id,$title,'title="'.$title.'"') ?></h2>
    <p><img style="margin-right: 5px;" alt="<?php echo $title ?>" title="<?php echo $title ?>" src="<?php echo $this->config->item('cdn_url').'exec/timthumb.php?src='._get_thumbnail($p) ?>&w=120&h=100" align="left"/><?php echo substr(strip_tags($desc),0,200) ?> ...</p>
    <p align="right"><?php echo anchor('news/c'.$post->cat_id.'/'.$alias.'-'.$post->post_id,'Xem tiếp','title="'.$title.'"') ?></p> 
</div>
<?php
        }
    }
?>
<div class="clear"></div>
<?php
 $pa = ceil($total/10); 
if(isset($_GET['page'])){   
    $p1 = $_GET['page']+1;
    $p2 = $_GET['page']-1;
    if($p2<1){
        $prev = '';
    }else
        $prev = '<a href="?page='.$p2.'">Lùi</a>';
    if($_GET['page']>=$pa){
        $next = '';
    }else
        $next = '<a href="?page='.$p1.'">Tới</a>';
    
}else{
    if($pa<2)
        $next = '';
    else
        $next = '<a href="?page=2">Tới</a>';
    $prev='';
}
$link = '';
for($i=1;$i<=$pa;$i++){
    if(isset($_GET['page']) && $_GET['page']==$i){
        $color='color:#000;font-weight:bold;border:1px solid #000';
    }else
        $color ='';
    $link.='<a style="padding:0 5px;'.$color.'" href="?page='.$i.'">'.$i.'</a>';
}
?>
<div align="right"><?php echo $prev.$link.$next; ?></div>
</div>
</div>


